﻿using System.Linq;
using GalaSoft.MvvmLight.Ioc;
using Tisbi.LawFirm.DAL.Models;

namespace Tisbi.LawFirm.BL.Services.Implementation
{
    public class EmployeeServiceAgent : ServiceAgentBase<Employees>, IEmployeesServiceAgent
    {
        private ICaseServiceAgent _caseServiceAgent;

        public EmployeeServiceAgent()
        {
            _caseServiceAgent = SimpleIoc.Default.GetInstance<ICaseServiceAgent>();
        }

        public bool HasCases(int employeeId)
        {
            bool has = false;
            _caseServiceAgent.GetCasesByEmployee(employeeId, (caseses, error) =>
            {
                if (error == null)
                {
                    has = caseses.Any();
                }
                else
                {
                    Notifyer.NotifyError("Unable to retrieve items", error);
                }
            });

            return has;
        }
    }
}
